tree-wide: [scan-build]: Add some asserts that pointers are non-NULL
authorColin Walters <walters@verbum.org>
Wed, 16 Oct 2019 13:44:46 +0000 (13:44 +0000)
committerColin Walters <walters@verbum.org>
Wed, 16 Oct 2019 13:44:46 +0000 (13:44 +0000)
More "scan-build doesn't understand GError and our out-param conventions"
AKA "these errors would be impossible with Rust's sum type Result<> approach".

src/libostree/ostree-sysroot-cleanup.c
src/libostree/ostree-sysroot.c
src/ostree/ot-builtin-fsck.c
src/ostree/ot-dump.c

index 7a352e6b4bdf2e6ee9197c6b946c75b84905baff..ef95d13c6b7b8b47dd5933912cb422c0f806617d 100644 (file)
@@ -313,6 +313,7 @@ cleanup_old_deployments (OstreeSysroot       *self,
   if (!list_all_deployment_directories (self, &all_deployment_dirs,
                                         cancellable, error))
     return FALSE;
+  g_assert (all_deployment_dirs); /* Pacify static analysis */
   for (guint i = 0; i < all_deployment_dirs->len; i++)
     {
       OstreeDeployment *deployment = all_deployment_dirs->pdata[i];
index e17cc2332ab4b1cd682af885c0a23562e8aefc71..1c9dbf379ca4892fe9877ab2d1fb4e28e8ac9b91 100644 (file)
@@ -945,6 +945,7 @@ ostree_sysroot_load_if_changed (OstreeSysroot  *self,
 
   g_autoptr(GPtrArray) deployments = g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
 
+  g_assert (boot_loader_configs); /* Pacify static analysis */
   for (guint i = 0; i < boot_loader_configs->len; i++)
     {
       OstreeBootconfigParser *config = boot_loader_configs->pdata[i];
index 5ad3bf38360bb132da4fef3156e2d78509a7208e..dea03af4381d371cd06338f118921a553fc2cc0d 100644 (file)
@@ -434,6 +434,7 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
   if (opt_add_tombstones)
     {
       guint i;
+      g_assert (tombstones); /* Pacify static analysis */
       if (tombstones->len)
         {
           if (!ot_enable_tombstone_commits (repo, error))
index 1ef63740eaa35cdab7dfdd6a7d9f422b3d6a4266..38f3730b84e215d7f7d21bec31e956ed02536e30 100644 (file)
@@ -125,7 +125,10 @@ dump_commit (GVariant            *variant,
   timestamp = GUINT64_FROM_BE (timestamp);
   str = format_timestamp (timestamp, &local_error);
   if (!str)
-    errx (1, "Failed to read commit: %s", local_error->message);
+    {
+      g_assert (local_error); /* Pacify static analysis */
+      errx (1, "Failed to read commit: %s", local_error->message);
+    }
   g_autofree char *contents = ostree_commit_get_content_checksum (variant) ?: "<invalid commit>";
   g_print ("ContentChecksum:  %s\n", contents);
   g_print ("Date:  %s\n", str);